// import breadcrumb from '../../common/breadcrumb'
import PageTemplate from '@/components/common/PageTemplate'
import need_deal_list from '../need_deal_list'
import need_deal_list2 from '../need_deal_list2'
import need_read_list from '../need_read_list'
import need_read_list2 from '../need_read_list2'
import need_aue_list from '../need_aue_list'
import {queryTaskTotalByApps} from '@/api/api.js'

export default {
    components:{
      PageTemplate,
        // breadcrumb,
        need_deal_list,
        need_deal_list2,
        need_read_list,
        need_read_list2,
        need_aue_list
    },
    data(){
        return {
            brand:[
                {name: 'lang.workbench'},
                {name: 'lang.need_deal_task'}
            ],
            hasIcon:false,
            showTabs:'1',
            containerWidth:0,
            type:'类型',
            status:'<img style="top:1px;position:relative;"  src="'+require('../../../assets/img/all.png')+'" /> '+ '所有',
            dateTime:'1',
            pic1:require('../../../assets/img/overtime.png'),
            pic2:require('../../../assets/img/soonovertime.png'),
            pic3:require('../../../assets/img/normal.png'),
            pic4:require('../../../assets/img/all.png'),
            listType:'2',
            keyword:'',
            taskDesc:'',
            launchTime:null,
            lastApproveMan:'',
            launcher:'',    
            searchParams:{},//查询参数返回给父组件
            showPopover:false,
            oa_num:0,
            upm_num:0,
            epm_num:0,
            pbs_num:0,
            appids: {
                "62C71C2F-9009-45CD-8B06-11361DB9EF71": "oa_num",
                "563DFA9D-6CCB-4553-869F-71220DF47413": "upm_num",
                "614B53E9-8C7B-4ADD-B7DA-48CF8F53745E": "epm_num",
                "53446519-C713-42DC-B07E-5FF51BB7BD9C": "pbs_num"
            }
        }
    },
    methods:{
        changeStatus:function(command){
            if(command == "超期"){
                this.status = '<img style="top:1px;position:relative;"  src="'+this.pic1+'" /> '  + command;
            }
            else if(command == "待完成"){
                this.status = '<img style="top:1px;position:relative;"  src="'+this.pic2+'" /> '  + command;
            }else if(command == "正常"){
                this.status = '<img style="top:1px;position:relative;"  src="'+this.pic3+'" /> '  + command;
            }else if(command == "所有"){
                this.status = '<img style="top:1px;position:relative;"  src="'+this.pic4+'" /> '  + command;
            }
            
        },
        changeType:function(command){
            if(command == "类型1"){
                this.type = "类型1";
            }else if(command == "类型2"){
                this.type = "类型2";
            }
        },
        changeTimeSort:function(){
            //1 为降序 2 为升序
            if(this.dateTime == "1"){
                this.dateTime = '2';
            }else{
                this.dateTime = '1';
            }
        },
        triggerList:function(obj){
            //切换展示列表形式  默认列表形式
            if(obj == "1"){
                this.listType = "1";
            }else{
                this.listType = "2";
            }
        },
        menu:function(){
            

        },
        resetData:function(){
            //重置
            this.launchTime = "";
            this.taskDesc = "";
            this.launcher = "";
        },
        advSearch:function(){
            //执行高级搜索操作
            this.searchParams = {
                launcher: this.launcher,
                taskDesc: this.taskDesc,
                launchTime: this.launchTime
            }
            this.showPopover = false;
            
        },
        //普通搜索
        commonSearch:function(){
            this.searchParams = {
                launcher:this.keyword
            }
        },
        getAueTaskTotal(params) {
            let _this = this;
            queryTaskTotalByApps(params).then((result) => {
                if(result.status == "200" && result.data.code == "0"){
                    let data = result.data.data.data;
                    for(var key in data) {
                        let div_num = _this.appids[key];
                        _this[div_num] = data[key];
                    }
                }else{
                    _this.$alert(result.data.msg,_this.$t('cm.tips'));
                }

            }).catch((err) => {
                _this.$alert(err,_this.$t('cm.tips'));
            });
        }
    },
    mounted() {
        this.containerWidth = document.body.scrollHeight -120;
        //获取统一待办数量
        // var _this = this;
        let params = {
            code: "queryTaskTotalByApps",
            tasktype: 0,
            appid: "614B53E9-8C7B-4ADD-B7DA-48CF8F53745E,563DFA9D-6CCB-4553-869F-71220DF47413,53446519-C713-42DC-B07E-5FF51BB7BD9C,62C71C2F-9009-45CD-8B06-11361DB9EF71"
        }
        this.getAueTaskTotal(params);
    },
    watch: {
        'containerWidth':function(newVal){
            //始终为滚动条的对应高度
        }
    },

}
